﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Vtron.LEDCorrective.Core;
using Vtron.LEDCorrective.Infrastructure;
using Vtron.LEDCorrective.Pages;

namespace Vtron.LEDCorrective
{
    /// <summary>
    /// CIEWindow.xaml 的交互逻辑
    /// </summary>
    public partial class CIEWindow : Window
    {
        ExpectedBrightColor expectedBrightColor = null;

        public CIEWindow()
        {
            InitializeComponent();
            Loaded += CIEWindow_Loaded;
        }

        public CIEWindow(ExpectedBrightColor expectedBrightColor):this()
        {
            this.expectedBrightColor = expectedBrightColor;
        }
        DoubleMatrix targetxyY = null;

        private void CIEWindow_Loaded(object sender, RoutedEventArgs e)
        {
            targetxyY = CorrectiveEngine.Instance.TargetxyY;
            List<Point> points = new List<Point> { new Point(targetxyY[0, 0], targetxyY[0, 1]), new Point(targetxyY[1, 0], targetxyY[1, 1]), new Point(targetxyY[2, 0], targetxyY[2, 1]) };
            cieUserControl.Points = points;
        }

        private void cancle_Btn_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void submit_Btn_Click(object sender, RoutedEventArgs e)
        {
            targetxyY[0, 0] = cieUserControl.Points[0].X;
            targetxyY[0, 1] = cieUserControl.Points[0].Y;
            targetxyY[1, 0] = cieUserControl.Points[1].X;
            targetxyY[1, 1] = cieUserControl.Points[1].Y;
            targetxyY[2, 0] = cieUserControl.Points[2].X;
            targetxyY[2, 1] = cieUserControl.Points[2].Y;

            expectedBrightColor.InitTargetxyY(targetxyY);
            Close();
        }
    }
}
